#ifndef __SERVER_HPP_
#define __SERVER_HPP_

#include <boost/bind.hpp>
#include <boost/timer.hpp>
#include <boost/asio.hpp>
#include <boost/shared_ptr.hpp>


    namespace network
    {

        class Server :
			private boost::noncopyable
        {
        public:


            /**
             * Server			default construction with xml parameters configuration
             */
            Server();

            /**
             * Server construction
             * @param adress    server address
             * @param port      listening port
             */
            Server(const std::string& address, const std::string& port);

            /**
             * Run the server
             */
            void run();

            /**
             * Stop the server
             */
            void stop();

            virtual ~Server()
            {
            };

            /**
             * Handle launched when a input connexion is detected
             * @param e    error code
             */
            virtual void handle_accept(const boost::system::error_code& e) = 0;
			
			bool isRunning();

        protected:



            /**
             * I/O service for the network
             */
            boost::asio::io_service m_ioService;

            /**
             * Connexions acceptor
             */
            boost::asio::ip::tcp::acceptor m_acceptor;

            /**
             * Event launched after the server is asked to shutdown
             */
            void handle_stop();

            std::string						m_address;
            std::string						m_port;
			std::string						m_serverName;
			std::vector<boost::uint16_t>	m_utf16ServerName;
			bool m_isRunning;


            /*
                    server(boost::asio::io_service& io_service);

                private:

                    void start_accept();
                    void handle_accept( CConnect::pointer new_connection, const boost::system::error_code& error );

                tcp::acceptor acceptor_;*/
        };

    } //  // namespace network


#endif // __SERVER_HPP_
